<?php

class IconHelper extends Helper
{
  
  const ICON = 'icon';
  
  const LABEL = 'label';
  
  const BOTH = 'both';
  
  public static $mode = 'icon';

  public static $icons = array(
    'view' => array('icons/magnifier.png', 'View'),
    'edit' => array('icons/pencil.png', 'Edit'),
    'remove' => array('icons/eraser.png', 'Remove'),
    'create' => array('icons/plus.png', 'Create'),
    'view_all' => array('icons/document-list.png', 'View All'),

    'top' => array('icons/control-stop-090.png', 'Top'),
    'up' => array('icons/control-090.png', 'Up'),
    'down' => array('icons/control-270.png', 'Down'),
    'bottom' => array('icons/control-stop-270.png', 'Bottom'),

    'first' => array('icons/control-stop-180.png', 'First'),
    'previous' => array('icons/control-180.png', 'Previous'),
    'next' => array('icons/control.png', 'Next'),
    'last' => array('icons/control-stop.png', 'Last'),

    'select_all' => array('icons/ui-check-box.png', 'All'),
    'select_none' => array('icons/ui-check-box-uncheck.png', 'None'),
    'select_invert' => array('icons/ui-check-boxes.png', 'Invert'),
    
    'logout' => array('icons/cross-octagon.png', 'Logout'),
  );

  public function show($action, $alt = null)
  {
    $output = '';

    if (! empty(self::$icons[$action])) {
      $icon = self::$icons[$action];

      $img = $icon[0];
      $alt = empty($alt) ? $icon[1] : $alt;

      switch (self::$mode) {
        case self::ICON:
          $output = $this->html->image($img, $alt);
          break;

        case self::LABEL:
          $output = $alt;
          break;

        case self::BOTH:
          $output = $this->html->image($img, $alt) . ' ' . $alt;
          break;
      }
    }
    else {
      $output = empty($alt) ? $action : $alt;
    }

    return $output;
  }

}

?>